package biz.obake.team.touchprotector.d.f;

import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import biz.obake.team.touchprotector.d.b;
import biz.obake.team.touchprotector.g.c;

public final class a extends b {

    /* renamed from: d  reason: collision with root package name */
    private Ringtone f1565d;
    private Ringtone e;
    private String f;

    private final void c() {
        Ringtone ringtone;
        d();
        if (biz.obake.team.touchprotector.donation.a.p()) {
            String c2 = c.c("TPService.State");
            if (!d.h.b.c.a(this.f, "Unlocked") || !d.h.b.c.a(c2, "Locked") ? !(!d.h.b.c.a(this.f, "Locked") || !d.h.b.c.a(c2, "Unlocked") || (ringtone = this.e) == null) : (ringtone = this.f1565d) != null) {
                ringtone.play();
            }
            this.f = c2;
        }
    }

    private final void d() {
        Ringtone[] ringtoneArr = {this.f1565d, this.e};
        for (int i = 0; i < 2; i++) {
            Ringtone ringtone = ringtoneArr[i];
            if (ringtone != null && ringtone.isPlaying()) {
                ringtone.stop();
            }
        }
    }

    private final void e(String str) {
        Ringtone ringtone;
        d();
        String l = biz.obake.team.touchprotector.g.a.l(str);
        if (l.length() == 0) {
            ringtone = null;
        } else {
            ringtone = RingtoneManager.getRingtone(biz.obake.team.android.a.a(), Uri.parse(l));
        }
        if (str != null) {
            int hashCode = str.hashCode();
            if (hashCode != -938375084) {
                if (hashCode == 1234969851 && str.equals("lock_sound")) {
                    this.f1565d = ringtone;
                }
            } else if (str.equals("unlock_sound")) {
                this.e = ringtone;
            }
        }
    }

    /* access modifiers changed from: protected */
    public void b(String str) {
        if (str != null) {
            int hashCode = str.hashCode();
            if (hashCode != -2066548004) {
                if (hashCode != -938375084) {
                    if (hashCode != 1234969851 || !str.equals("lock_sound")) {
                        return;
                    }
                } else if (!str.equals("unlock_sound")) {
                    return;
                }
                e(str);
            } else if (str.equals("TPService.State")) {
                c();
            }
        }
    }

    public void start() {
        super.start();
        this.f = c.c("TPService.State");
        e("lock_sound");
        e("unlock_sound");
    }

    public void stop() {
        super.stop();
        d();
    }
}
